﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WXYW.BLL;
using WXYW.Model;

namespace WXYW
{
    public partial class YJTJBasedOnFC : System.Web.UI.Page
    {
        public List<YJModelBasedOnFC> ModelList;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                for (int startYear = 2010; startYear <= DateTime.Now.Year; startYear++)
                {
                    YearDDL.Items.Add(new ListItem(startYear.ToString(), startYear.ToString()));
                }

                for (int month = 1; month <= 12; month++)
                {
                    MonthDDL.Items.Add(new ListItem(month.ToString(), month.ToString()));
                }

                YearDDL.SelectedValue = DateTime.Now.Year.ToString();
                MonthDDL.SelectedValue = DateTime.Now.Month.ToString();
                BindData();
            }
        }

        private void BindData()
        {
            YJTJService service = new YJTJService();
            ModelList = service.GetYJModelInfoBasedOnFC(DateTime.Now.Year, DateTime.Now.Month);
        }

        protected void OKBtn_Click(object sender, EventArgs e)
        {
            YJTJService service = new YJTJService();
            ModelList = service.GetYJModelInfoBasedOnFC(Convert.ToInt32(YearDDL.SelectedValue), 
                Convert.ToInt32(MonthDDL.SelectedValue));
        }

        public string GenerateURL(string providerCode)
        {
            return string.Format("YJTJBasedOnFCDetail.aspx?{0}={1}&{2}={3}&{4}={5}", Constants.QUERYSTR_PROVIDERCODE, providerCode,
                Constants.QUERYSTR_YEAR, YearDDL.SelectedValue,
                Constants.QUERYSTR_MONTH, MonthDDL.SelectedValue);
        }
    }
}
